function * foo() {
    console.log(' start')
    try {
        // console.log('yield')
        const res = yield 'foo' // `yield`是暂停  generator.next('2') 的参数会被赋值给 res 
        // console.log('continue')
        console.log(res)
    } catch (e) {
        console.log(e)
    }
}
const generator = foo();
generator.next(); // => start yield
// generator.next(); // => continue undefined
const result = generator.next('2');
console.log(result); // => { value: 'foo', done: false }

// generator.next( 'bar' ); // => bar 在`yield`后继续执行，

// generator.throw(new Error('Generator error')); // => Error: Generator error
